package com.chixing.service.impl;

import com.chixing.mapper.GoodMapper;
import com.chixing.pojo.Good;
import com.chixing.pojo.GoodExample;
import com.chixing.service.GoodService;
import com.chixing.util.ServerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class GoodServiceImpl implements GoodService {

  @Autowired
  private GoodMapper goodMapper;

  @Override
  public ServerResult getByCusId(Integer cusId) {

    GoodExample goodExample = new GoodExample();
    GoodExample.Criteria criteria = goodExample.createCriteria();
    criteria.andCustomerIdEqualTo(cusId);

    List<Good> goods = goodMapper.selectByExample(goodExample);
    if (goods.size() > 0) {
      return ServerResult.getSuccess(goods);
    }
    else
      return ServerResult.getFail(null);
  }
}
